Passed
Pull Request — master (#84)
by Mathieu
01:25
created

User.getEntryDate   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import {Entity, Column, PrimaryGeneratedColumn, Index} from 'typeorm';
2
3
@Entity()
4
export class User {
5
  @PrimaryGeneratedColumn('uuid')
6
  private id: string;
7
8
  @Column({type: 'varchar', nullable: false})
9
  private firstName: string;
10
11
  @Column({type: 'varchar', nullable: false})
12
  private lastName: string;
13
14
  @Column({type: 'varchar', unique: true, nullable: false})
15
  private email: string;
16
17
  @Index('api-token')
18
  @Column({type: 'varchar', nullable: true})
19
  private apiToken: string;
20
21
  @Column({type: 'varchar', nullable: false})
22
  private password: string;
23
24
  @Column({type: 'timestamp', nullable: false})
25
  private entryDate: string;
26
27
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
28
  private createdAt: Date;
29
30
  constructor(
31
    firstName: string,
32
    lastName: string,
33
    email: string,
34
    apiToken: string,
35
    password: string,
36
    entryDate: string
37
  ) {
38
    this.firstName = firstName;
39
    this.lastName = lastName;
40
    this.email = email;
41
    this.apiToken = apiToken;
42
    this.password = password;
43
    this.entryDate = entryDate;
44
  }
45
46
  public getId(): string {
47
    return this.id;
48
  }
49
50
  public getFirstName(): string {
51
    return this.firstName;
52
  }
53
54
  public getLastName(): string {
55
    return this.lastName;
56
  }
57
58
  public getEmail(): string {
59
    return this.email;
60
  }
61
62
  public getApiToken(): string {
63
    return this.apiToken;
64
  }
65
66
  public getPassword(): string {
67
    return this.password;
68
  }
69
70
  public getEntryDate(): string {
71
    return this.entryDate;
72
  }
73
74
  public getFullName(): string {
75
    return `${this.firstName} ${this.lastName}`;
76
  }
77
78
  public update(firstName: string, lastName: string, email: string): void {
79
    this.firstName = firstName;
80
    this.lastName = lastName;
81
    this.email = email;
82
  }
83
84
  public updatePassword(password: string): void {
85
    this.password = password;
86
  }
87
}
88